package o;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Build;
import android.os.Build.VERSION;
import android.view.View;
import android.view.Window;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.lang.reflect.InvocationTargetException;

public class evd {
    private static boolean ˊ = ॱ();
    private static boolean ˎ = ˏ();

    public static boolean ˎ() {
        return ˊ || !ˎ;
    }

    private static boolean ॱ() {
        boolean ˋ = bmm.getSystemProperty("ro.config.hw_tint", false);
        Logger.ˎ("StatusBarColor", "isNewHint: " + ˋ);
        return ˋ;
    }

    private static boolean ˏ() {
        boolean equalsIgnoreCase = Build.BRAND.equalsIgnoreCase("huawei");
        Logger.ˎ("StatusBarColor", "Brand: " + Build.BRAND);
        if (equalsIgnoreCase) {
            return true;
        }
        equalsIgnoreCase = Build.MANUFACTURER.equalsIgnoreCase("huawei");
        Logger.ˎ("StatusBarColor", "Manufacturer: " + Build.MANUFACTURER);
        if (equalsIgnoreCase) {
            return true;
        }
        return false;
    }

    public static void ˏ(Window window) {
        if (ˊ) {
            View decorView = window.getDecorView();
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | WXMediaMessage.DESCRIPTION_LENGTH_LIMIT);
            window.setStatusBarColor(0);
            return;
        }
        window.addFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
    }

    public static void ॱ(Activity activity, @ColorRes int i) {
        ˋ(activity, i, i);
    }

    public static void ˋ(Activity activity, @ColorRes int i, @ColorRes int i2) {
        ˎ(activity.getWindow(), i, i2);
    }

    public static void ˊ(@NonNull Activity activity, int i, int i2) {
        Window window = activity.getWindow();
        window.clearFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(Integer.MIN_VALUE);
        window.setStatusBarColor(i);
        ˊ(window);
        window.setNavigationBarColor(i2);
        ॱ(window);
    }

    private static void ॱ(Window window) {
        if (!ˎ()) {
            return;
        }
        if (erq.ˏ(window.getNavigationBarColor())) {
            ॱ(window, 1);
        } else {
            ॱ(window, 0);
        }
    }

    @SuppressLint({"ResourceType"})
    public static void ˎ(@NonNull Window window, @ColorRes int i, @ColorRes int i2) {
        if (i > 0) {
            window.clearFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(Integer.MIN_VALUE);
            window.setStatusBarColor(window.getContext().getResources().getColor(i));
            ˊ(window);
        }
        if (i2 > 0) {
            window.setNavigationBarColor(window.getContext().getResources().getColor(i2));
            ॱ(window);
        }
    }

    private static void ˊ(@NonNull Window window) {
        int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
        if (Build.MANUFACTURER.equalsIgnoreCase("VIVO") || Build.MANUFACTURER.equalsIgnoreCase("OPPO")) {
            if (VERSION.SDK_INT >= 23) {
                systemUiVisibility |= 8192;
            } else {
                systemUiVisibility |= 16;
            }
        }
        if (ˋ()) {
            systemUiVisibility |= 8192;
            ˎ(window);
        }
        window.getDecorView().setSystemUiVisibility(systemUiVisibility);
    }

    public static void ॱ(Window window, int i) {
        if (ˎ() && VERSION.SDK_INT >= 26) {
            if (i == 1) {
                window.getDecorView().setSystemUiVisibility(window.getDecorView().getSystemUiVisibility() & -17);
            } else if (i == 0) {
                window.getDecorView().setSystemUiVisibility(window.getDecorView().getSystemUiVisibility() | 16);
            }
        }
    }

    public static void ˏ(Window window, int i) {
        if (ˎ() && VERSION.SDK_INT >= 23) {
            if (i == 1) {
                window.getDecorView().setSystemUiVisibility(window.getDecorView().getSystemUiVisibility() & -8193);
            } else if (i == 0) {
                window.getDecorView().setSystemUiVisibility(window.getDecorView().getSystemUiVisibility() | 8192);
            }
        }
    }

    public static void ˊ(Window window, int i) {
        if (ˎ() && VERSION.SDK_INT >= 26) {
            if (i == 1) {
                window.getDecorView().setSystemUiVisibility((window.getDecorView().getSystemUiVisibility() & -8193) & -17);
            } else if (i == 0) {
                window.getDecorView().setSystemUiVisibility((window.getDecorView().getSystemUiVisibility() | 8192) | 16);
            }
        }
    }

    private static void ˎ(@NonNull Window window) {
        Class cls = window.getClass();
        try {
            Class cls2 = Class.forName("android.view.MiuiWindowManager$LayoutParams");
            int i = cls2.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE").getInt(cls2);
            cls.getMethod("setExtraFlags", new Class[]{Integer.TYPE, Integer.TYPE}).invoke(window, new Object[]{Integer.valueOf(i), Integer.valueOf(i)});
        } catch (ClassNotFoundException e) {
            Logger.ˎ("StatusBarColor", "ClassNotFoundException");
        } catch (NoSuchFieldException e2) {
            Logger.ˎ("StatusBarColor", "NoSuchFieldException");
        } catch (IllegalAccessException e3) {
            Logger.ˎ("StatusBarColor", "IllegalAccessException");
        } catch (NoSuchMethodException e4) {
            Logger.ˎ("StatusBarColor", "NoSuchMethodException");
        } catch (InvocationTargetException e5) {
            Logger.ˎ("StatusBarColor", "InvocationTargetException");
        }
    }

    private static boolean ˋ() {
        return ˎ("ro.miui.ui.version.code") || ˎ("ro.miui.ui.version.name") || ˎ("ro.miui.internal.storage");
    }

    private static boolean ˎ(String str) {
        return !dof.ॱ(bmm.getSystemProperty(str, ""));
    }
}
